package com.wn.ziroom.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wn.ziroom.entity.Quarters;
import com.wn.ziroom.service.QuartersService;
import com.wn.ziroom.vo.QuarterInMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wangzhijia
 * @since 2023-02-24 12:54:35
 */
@Controller
@RequestMapping("/quarters")
public class QuartersController {

    @Autowired
    private QuartersService quartersService;


    @GetMapping("/getAll")
    public String getAll(Map<String, Object> map) {
        List<QuarterInMap> quarterInMaps = quartersService.getAllForMap();

        map.put("qs", quarterInMaps);
        Double[] t = new Double[2];
        Arrays.fill(t, 121.47715);
        Arrays.fill(t, 31.231829);


        map.put("t", t);

        return "room/RoomMap.html";
    }

    @GetMapping("/map")
    @ResponseBody
    public List<Quarters> map(Map<String, Object> map) {
//        LambdaQueryWrapper<Quarters> quartersLambdaQueryWrapper = new LambdaQueryWrapper<>();
//        quartersLambdaQueryWrapper.select(Quarters::getLongitudeLatitude);
        List<Quarters> list = quartersService.list();
        return list;
    }

}

